package com.cheng.config;

import net.hasor.core.ApiBinder;
import net.hasor.core.DimModule;
import net.hasor.db.JdbcModule;
import net.hasor.db.Level;
import net.hasor.spring.SpringModule;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @author cheng-qiang
 * @date 2022年08月12日15:50
 */
@DimModule
@Component
public class ExampleModule implements SpringModule {

    @Resource
    private DataSource dataSource = null;

    @Override
    public void loadModule(ApiBinder apiBinder) throws Throwable {
        // 把 Spring 中的数据源设置到 Hasor
        apiBinder.installModule(new JdbcModule(Level.Full, this.dataSource));
    }
}